

@BindingAdapter(
    value = ["refreshing", "moreLoading", "hasMore"],
    requireAll = false
)
fun bindSmartRefreshLayout(
    smartLayout: SmartRefreshLayout,
    refreshing: Boolean,
    moreLoading: Boolean,
    hasMore: Boolean
) {//状态绑定，控制停止刷新
    if (!refreshing) smartLayout.finishRefresh()
    if (!moreLoading) smartLayout.finishLoadMore()
}


@BindingAdapter(value = ["listdata", "itemClick", "itemLongClick"])
fun bind[name]Adapter(
    recyclerView: RecyclerView,
    data: ObservableArrayList<[name]Item>,
    onItemClick: ((type:Int,bean:[name]Item)->Unit) ?= null,
    itemLongClick: ((resId:Int,bean:[name]Item)->Unit) ?= null
) {
    val layoutManager = LinearLayoutManager(recyclerView.context)
    recyclerView.layoutManager = layoutManager
    val adapter = [name]Adapter(data)
    adapter.onItemClick = itemClick
    adapter.itemLongClickListener = itemLongClick
    recyclerView.adapter = adapter
}
